﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FEM.Result;

namespace PBSD_Development
{
    /// <summary>
    /// 模态信息
    /// </summary>
    public class ModeSet
    {
        /// <summary>
        /// 周期字典
        /// </summary>
        private Dictionary<int, double> periodDict { set; get; }

        /// <summary>
        /// 模态数量
        /// </summary>
        public int Count
        {
            get
            {
                return this.periodDict.Count;
            }
        }

        /// <summary>
        /// 获得周期
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public double GetPeriod(int id)
        {
            return this.periodDict.ContainsKey(id) ? this.periodDict[id] : -1;
        }

        /// <summary>
        /// 空的构造函数
        /// </summary>
        public ModeSet()
        {
            //实例化
            this.periodDict = new Dictionary<int, double>();
        }

        /// <summary>
        /// 模态信息 YJK
        /// </summary>
        /// <param name="result"></param>
        public ModeSet(FEMResult result): this()
        {
            //测定登录状态
            if (!Login.LoginState.Check()) return;
            //获得结构信息
            var modelInfo = result.GetStructInfo;
            //遍历模态
            foreach (var kvp in modelInfo.ModeDic)
                this.periodDict.Add(kvp.Key, kvp.Value.Period);
        }

    }
}
